package com.example.springsecurity.handler;

import com.example.springsecurity.pojo.R;
import com.example.springsecurity.util.ResponseUtils;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: anwenbiao
 * @Description: TODO 认证端点
 * @DateTime: 2023/2/5 8:43
 */
@Component
public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {
    
    
    
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        ResponseUtils.sendWirte(response, R.faild("请求需要登录"));
    }
}
